package efg.library.EJB;

import javax.ejb.Stateless;

import efg.library.IF.LibraryAdminIF;

@Stateless
public class LibraryAdminBean implements LibraryAdminIF
{ 
  public LibraryAdminBean()
  {
    System.out.println("LibraryAdmin()");
  }
  
  public String[] check(String usr, String pwd)
  {
    System.out.println("- EJB: LibraryAdmin.check("+usr+", "+pwd+")");
    LibraryPrincipal principal = LibraryPrincipal.findLibraryPrincipal(usr);
    if (principal != null && pwd.equals(principal.getPassword()))
    {
    	System.out.println("- EJB: roles: "+principal);
      return principal.getRoles();
    }
    System.out.println("- EJB: not a valid user!");
    return null;
  }
}
